package com.heatup.apt.common.dao;

import com.heatup.apt.model.coupon.CouponCheck;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface CouponCheckMapper {
    @Delete({
        "delete from coupon_check",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into coupon_check (id, name, ",
        "phone, is_valid)",
        "values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, ",
        "#{phone,jdbcType=VARCHAR}, #{isValid,jdbcType=TINYINT})"
    })
    int insert(CouponCheck record);

    int insertSelective(CouponCheck record);

    @Select({
        "select",
        "id, name, phone, is_valid",
        "from coupon_check",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    CouponCheck selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(CouponCheck record);

    @Update({
        "update coupon_check",
        "set name = #{name,jdbcType=VARCHAR},",
          "phone = #{phone,jdbcType=VARCHAR},",
          "is_valid = #{isValid,jdbcType=TINYINT}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(CouponCheck record);


    /**
     * 查询优惠券校验人列表
     * @return
     */
    List<CouponCheck> queryAllCheckList(Integer type);
}